
--EXAMPLE USE
--select dbo.sipre_RemoveNonNumericCharacters('as12dfd5')

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[siodge_RemoveNonNumericCharacters]'))
drop function [dbo].[siodge_RemoveNonNumericCharacters]
GO

CREATE Function siodge_RemoveNonNumericCharacters(@strText VARCHAR(1000))
RETURNS VARCHAR(1000)
AS
BEGIN
    WHILE PATINDEX('%[^0-9]%', @strText) > 0
    BEGIN
        SET @strText = STUFF(@strText, PATINDEX('%[^0-9]%', @strText), 1, '')
    END
    RETURN @strText
END

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO